﻿#ifndef CLOSABLELISTWIDGET_H
#define CLOSABLELISTWIDGET_H

#include "components/FWidgets/FListWidget/FListWidget.h"
#include "ClosableListWidgetItem.h"

class ClosableListWidget : public FListWidget
{
    Q_OBJECT
public:
    explicit ClosableListWidget(QWidget *parent = nullptr);

    ClosableListWidgetItem* addItem(const QString &text);
    ClosableListWidgetItem* addItem(const QIcon& icon, const QString& text);
    ClosableListWidgetItem* addItem(ClosableListWidgetItem* item);
    ClosableListWidgetItem* insertItem(int row, const QString &text);
    ClosableListWidgetItem* insertItem(int row, const QIcon& icon, const QString &text);
    ClosableListWidgetItem* insertItem(int row, ClosableListWidgetItem* item);

    void closeItem(int row);

    ClosableListWidgetItem *item(int row) const;
    int row(ClosableListWidgetItem* item) const;

signals:
    void itemCloseRequested(int row);
    void itemActivated(ClosableListWidgetItem* item);
    void itemClicked(ClosableListWidgetItem* item);
    void itemRemoved(const QString& text);

private slots:
    void onItemCloseRequested();
    void onParentItemActivated(QListWidgetItem* item);
    void onParentItemClicked(QListWidgetItem* item);

private:
};

#endif // CLOSABLELISTWIDGET_H
